﻿#if UNITY_EDITOR
using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Editor;
using Sirenix.Utilities;
using Sirenix.Utilities.Editor;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MainSkillEditerLayer : OdinEditorWindow
{
    [Title("配置场景数据然后点击\"开始调试\"按钮", Subtitle = "", TitleAlignment = TitleAlignments.Centered, Bold = true, HorizontalLine = true)]
    [HideLabel]
    [DisplayAsString]
    public string myTitle= "场景配置";

    [MenuItem("MyTools/SkillEditor")]
    private static void OpenWindow()
    {
        var window = GetWindow<MainSkillEditerLayer>();
        window.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 500);

        GUIContent titleContent = new GUIContent("调试启动", "");
        window.titleContent = titleContent;
        
        var bulletShapeEditerLayer = EditorWindow.GetWindow<SkillEditerLayer>("技能编辑", typeof(MainSkillEditerLayer));

        //window.Focus();
        bulletShapeEditerLayer.Focus();
    }

    [Button]
    [LabelText("开始调试")]
    private void CloseAndRun()
    {

        if (!Application.isPlaying)
        {
            EditorSceneManager.SaveScene(SceneManager.GetActiveScene(), "", false);
        }

        EditorApplication.ExecuteMenuItem("Edit/Play");

        EditorWindow.GetWindow<SkillEditerLayer>().Close();
        GetWindow<MainSkillEditerLayer>().Close();

    }
}

#endif